﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SlideShow.ascx.cs" Inherits="Controls_MenuLeft" %>
<%@ Import Namespace="webapp4U" %>
<%@ Import Namespace="System.IO" %>

<table width="185" border="0" cellpadding="0" cellspacing="0" class="photo-frame"
    align="center">
    <tr>
        <td class="topx--">
        </td>
        <td class="top-x-">
        </td>
        <td class="top--x">
        </td>
    </tr>
    <tr>
        <td class="midx--">
        </td>
        <td bgcolor="white" style="padding-left: 6px; padding-right: 6px" align="center">
              <table width="100%" border="0" height="178px" cellpadding="0" cellspacing="0">
                <tr>
                    <td valign="top" align="center">
                        <img border="0" src="<%=Globals.ImagesUrl() %>slideshow.bmp" width="168" height="175" id="imageSlides" style="filter: revealTrans(duration=2,transition=5); border: 0px solid red" title="Slide Show">
                        
                        <SCRIPT language="javascript">
                            var imgArray = new Array;
                            <%
                              // khai bao stt lam bien toan cuc luon
                              int stt = 0;
                              string jscript = "";     
                              DirectoryInfo d = new DirectoryInfo(Request.PhysicalApplicationPath + "UserUpload/SlideShow");
                              foreach (FileInfo f in d.GetFiles())
                              {
                                  jscript += "imgArray[" + stt + "]='" + Globals.ApplicationPath +
                                     "UserUpload/SlideShow/" + f.Name + "$$$;'";
                                  jscript += "\n";
                                  stt = stt + 1;
                              }
                              
                              Response.Write(jscript);
                            %>
                            
                            var currImg = parseInt(Math.random()* parseInt(<%=stt%>) );
                            var ns=(navigator.appName.indexOf("Netscape")!=-1);
                            var img=document.getElementById('imageSlides');
                            doTransslide(currImg);
                            
                            function doTransslide()
                            {
                                if (currImg==imgArray.length) 
                                    currImg=0;
                                                        
                                if(navigator.appName=="Microsoft Internet Explorer")
                                {
                                    var part=imgArray[currImg].split("$$$");
                                    var srcimage=part[0];
                                    var url=part[1];
                                    img.filters[0].apply();
                                    document.images[img.id].src=srcimage;
                                    document.images[img.id].alt=url;
                                    document.getElementById(img.id).filters[0].transition = 12;
                                    document.getElementById(img.id).filters[0].play();
                                }
                                else
                                {
                                    var ImageURL=imgArray[currImg].split("$$$").toString();
                                    ImageURL=ImageURL.replace(";","").replace(",","");
                                    document.images[img.id].src=ImageURL;
                                }
                                
                                currImg = parseInt(Math.random()* parseInt(<%=stt %>) );
                            }
                            
                            setInterval('doTransslide()',10000);
                        </SCRIPT>

                    </td>
                </tr>
            </table>
        </td>
        <td class="mid--x">
        </td>
    </tr>
    <tr>
        <td class="botx--">
        </td>
        <td class="bot-x-">
        </td>
        <td class="bot--x">
        </td>
    </tr>
</table>


